package middlecontent.loader;

/**
 * @Author: fxy
 * @Date: 2022/02/08/14:01
 * @Description:
 */
public class ClassLoaderTest {
    //系统类加载器和扩展类加载器本身由引导类加载器加载
    public static void main(String[] args) {
        //获取系统类加载器
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);

        //获取其上层，扩展类加载器
        ClassLoader extClassLoader = systemClassLoader.getParent();
        System.out.println(extClassLoader);

        //获取不到引导类加载器
        ClassLoader parent = extClassLoader.getParent();
        System.out.println(parent);

        //默认使用系统类加载器 加载 用户自定义类
        ClassLoader classLoader = ClassLoaderTest.class.getClassLoader();
        System.out.println(classLoader);

        //String， java核心类库通过引导类加载器加载（启动类加载器）并不继承ClassLoader
        ClassLoader classLoader1 = String.class.getClassLoader();
        System.out.println(classLoader1);
    }
}
